package TestDemo;

import java.util.Stack;

public class Main {
    public boolean isNumber(String token) {
        return !("+".equals(token) || "-".equals(token) || "*".equals(token) || "/".equals(token));
    }
    public int evalRPN(String[] tokens) {
        Stack<Integer> s = new Stack<>();
        int i = 0;
        while (i < tokens.length){
            if (isNumber(tokens[i])){
                int val = Integer.valueOf(tokens[i]);
                s.push(val);
            } else {
                if (tokens[i].equals("+")){
                    int a = s.pop();
                    int b = s.pop();
                    s.push(b+a);
                } else if (tokens[i].equals("-")) {
                    int a = s.pop();
                    int b = s.pop();
                    s.push(b-a);
                } else if (tokens[i].equals("*")) {
                    int a = s.pop();
                    int b = s.pop();
                    s.push(b*a);
                } else {
                    int a = s.pop();
                    int b = s.pop();
                    s.push(b/a);
                }
            }
            i++;
        }
        return s.pop();
    }
    public static void main(String[] args) {
        MyLinkedList myLinkedList = new MyLinkedList();
        myLinkedList.addFirst(1);
        myLinkedList.addFirst(5);
        myLinkedList.addFirst(1);
        myLinkedList.addLast(1);
        myLinkedList.addLast(1);
        myLinkedList.display();
        System.out.println("=====================");
        //myLinkedList.removeAllKey(1);
        myLinkedList.clear();
        myLinkedList.display();
    }
}
